home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 1
/
Cream of the Crop 1.iso
/
PROGRAM
/
TGCBOR20.ARJ
/
INTROPAK.COM
/
PCXDEMO.C
< prev
next >
Wrap
C/C++ Source or Header
|
1991-08-28
|
8KB
|
379 lines
#include <teglsys.h>
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include "pcxdemo.inc"
int ix1,iy1,ix2,iy2;
/* NOTE! when linking you must also specify the lips2.obj file */
void cdecl lipspcxproc(void);
unsigned char userpressingbutton(imagestkptr fs,msclickptr ms)
{
unsigned mxpos,mypos;
unsigned stat;
msclickptr ms1;
stat = mouseposition(&mxpos,&mypos);
if (functionkeycode == 0)
ms1 = checkmouseclickpos(fs,mxpos,mypos);
else {
stat = scancodetable[functionkeycode & 0x00ff];
ms1 = ms;
}
return (ms1 == ms) && (stat != 0);
}
unsigned viewsecondscreen(imagestkptr ifs,msclickptr ms)
{
int ax,ay;
hidemouse();
ax = ms->ms.x & 0xfff8;
ay = ms->ms.y;
movestackimage(ifs,ax,ay);
showmouse();
return 1;
}
unsigned bouncedemo(imagestkptr ifs,msclickptr ms)
{
unsigned char d,e,r;
int x,y,ct;
if (visualsquarebuttonpress(ifs,ms)) {
hidemouse();
x = ifs->x + 16;
y = ifs->y + 16;
ix1 = ix1 & 0xfff8;
ix2 = ix1 + 368;
while (kbhit())
getch();
d = TRUE;
e = TRUE;
r = TRUE;
ct = 1;
do {
if (d) {
while ((iy2 < 338) && (!kbhit()) && (!mouse_buttons)) {
movevideopixels(ix1,iy1,ix2,iy2,x,y,0,0,TGMK_FP(0xa000,0x9600),TGMK_FP(0xa000,0x0000));
iy1 += ct;
iy2 += ct;
}
if (iy2 > 338) {
iy1 -= ct;
iy2 -= ct;
}
} else {
while ((iy1 > 0) && (!kbhit()) && (!mouse_buttons)) {
movevideopixels(ix1,iy1,ix2,iy2,x,y,0,0,TGMK_FP(0xa000,0x9600),TGMK_FP(0xa000,0x0000));
iy1 -= ct;
iy2 -= ct;
}
if (iy1 < 0) {
iy1 += ct;
iy2 += ct;
}
}
d = !d;
if (e) {
ix1 += 8;
ix2 += 8;
} else {
ix1 -= 8;
ix2 -= 8;
}
if (ix2 > 639) {
ix1 -= 8;
ix2 -= 8;
e = !e;
} else if (ix1 < 0) {
ix1 += 8;
ix2 += 8;
e = !e;
}
if (r) {
ct++;
if (ct > 10)
r = !r;
} else {
ct--;
if (ct == 1)
r = !r;
}
} while (!((kbhit()) || (mouse_buttons)));
showmouse();
while (kbhit())
getch();
while (mouse_buttons) {}
releasesquarebutton(ifs,ms);
}
return 1;
}
unsigned shiftvert(imagestkptr ifs,msclickptr ms)
{
int x,y,x1,y1;
presssquarebutton(ifs,ms);
x = ifs->x + 16;
y = ifs->y + 16;
x1 = x + 368 + 16;
y1 = y + 168 + 16;
prepareforpartialupdate(ifs,x,y,x1,y1);
do {
switch (ms->clicknumber) {
/* /\ */case 7:{
iy1 -= 8;
iy2 -= 8;
}
break;
/* \/ */case 8:{
iy1--;
iy2--;
}
break;
/* /\ */case 9:{
iy1++;
iy2++;
}
break;
case 10:{
iy1 += 8;
iy2 += 8;
}
break;
}
if (iy1 < 0) {
iy1 = 0;
iy2 = 168;
} else if (iy2 > 338) {
iy1 = 338 - (iy2 - iy1);
iy2 = 338;
}
movevideopixels(ix1,iy1,ix2,iy2,x,y,0,0,TGMK_FP(0xa000,0x9600),TGMK_FP(0xa000,0x0000));
} while (userpressingbutton(ifs,ms));
commitupdate();
releasesquarebutton(ifs,ms);
return 1;
}
unsigned scrollhorz(imagestkptr ifs,msclickptr ms)
{
int x,y,x1,y1;
presssquarebutton(ifs,ms);
x = ifs->x + 16;
y = ifs->y + 16;
x1 = x + 368;
y1 = y + 168;
prepareforpartialupdate(ifs,x,y,x1,y1);
do {
switch (ms->clicknumber) {
/* .< */case 11:
movevideopixels(x,y,x1,y1,x,y,0,8,TGMK_FP(0xa000,0x0000),TGMK_FP(0xa000,0x0000));
break;
/* .> */case 13:
movevideopixels(x,y,x1,y1,x,y,0,-8,TGMK_FP(0xa000,0x0000),TGMK_FP(0xa000,0x0000));
break;
}
} while (userpressingbutton(ifs,ms));
commitupdate();
releasesquarebutton(ifs,ms);
return 1;
}
unsigned scrollvert(imagestkptr ifs,msclickptr ms)
{
int x,y,x1,y1;
presssquarebutton(ifs,ms);
x = ifs->x + 16;
y = ifs->y + 16;
x1 = x + 368;
y1 = y + 168;
prepareforpartialupdate(ifs,x,y,x1,y1);
do {
switch (ms->clicknumber) {
/* .^ */case 12:
movevideopixels(x,y,x1,y1,x,y,-8,0,TGMK_FP(0xa000,0x0000),TGMK_FP(0xa000,0x0000));
break;
/* .v */case 14:
movevideopixels(x,y,x1,y1,x,y,8,0,TGMK_FP(0xa000,0x0000),TGMK_FP(0xa000,0x0000));
break;
}
} while (userpressingbutton(ifs,ms));
commitupdate();
releasesquarebutton(ifs,ms);
return 1;
}
unsigned shifthorz(imagestkptr ifs,msclickptr ms)
{
int x,y,x1,y1;
presssquarebutton(ifs,ms);
x = ifs->x + 16;
y = ifs->y + 16;
x1 = x + 368;
y1 = y + 168;
prepareforpartialupdate(ifs,x,y,x1,y1);
do {
switch (ms->clicknumber) {
/* << */case 3:{
ix1 -= 8;
ix2 -= 8;
ix2 = ix2 - (ix1 & 7);
ix1 = ix1 & 0xfff8;
}
break;
/* < */ case 4:{
ix1--;
ix2--;
}
break;
/* > */ case 5:{
ix1++;
ix2++;
}
break;
/* >> */case 6:{
ix1 += 8;
ix2 += 8;
ix2 = ix2 - (ix1 & 7);
ix1 = ix1 & 0xfff8;
}
break;
}
if (ix1 < 0) {
ix1 = 0;
ix2 = 368;
} else if (ix2 > 639) {
ix1 = 639 - (ix2 - ix1);
ix2 = 639;
}
movevideopixels(ix1,iy1,ix2,iy2,x,y,0,0,TGMK_FP(0xa000,0x9600),TGMK_FP(0xa000,0x0000));
} while (userpressingbutton(ifs,ms));
commitupdate();
releasesquarebutton(ifs,ms);
return 1;
}
unsigned exitoption(imagestkptr ifs,msclickptr ms)
{
if (visualsquarebuttonpress(ifs,ms))
abortexit("TEGL PCX Graphics DEMO");
return 1;
}
void main(void)
{
maxwindowsize = 128000;
setvideochoices(TG_CGA,FALSE);
setvideochoices(TG_HGC,FALSE);
setvideochoices(TG_EGA,FALSE);
registertgidriver(GREVGA16_driver);
setstandardheapsize(64000L);/* Reserve about 32k for Video Drivers */
teglinit(videoautodetect(),20480);
quickshowpcxfile("TEGLLOGO.PCX",TRUE,0,getmaxy(),getmaxx());
ippushimage(0,0,319,239);
if (getmaxy() > 400) {
ipputimage(320,0,ipstack,FGNORM);
ipputimage(0,240,ipstack,FGNORM);
ipsetcoord(ipstack,320,240,639,479);
} else
ipsetcoord(ipstack,320,108,639,347);
ippopimage();
setpcxbwmap(0xff,0xff,0xff,0xff);
/* there are only 27k bytes left on the second portion of the VGA */
/* thus you can get only about 338 lines. */
displaypcxfile(lipspcxproc,TRUE,0x9600,338,getmaxx());
setpalette(DARKGRAY,48);
pushimage(80,100,480,325);
bevelboxfs(stackptr,0,0,400,225,WHITE,LIGHTGRAY,LIGHTGRAY,8);
bevelboxfs(stackptr,8,8,392,192,LIGHTGRAY,WHITE,LIGHTGRAY,7);
setmoveframecallproc(stackptr,viewsecondscreen);
movevideopixels(96,96,464,264,96,116,0,0,TGMK_FP(0xa000,0x9600),TGMK_FP(0xa000,0x0000));
ix1 = 96;
iy1 = 96;
ix2 = 464;
iy2 = 264;
definesquarebuttontext(stackptr,8,192,57,217,10,4,"QUIT",exitoption);
definesquarebuttontext(stackptr,57,192,110,217,12,4,"DEMO",bouncedemo);
definesquarebuttonclick(stackptr,110,192,140,217,4,7,imageSHFTLL,shifthorz);
definesquarebuttonclick(stackptr,140,192,170,217,4,7,imageSHFTL,shifthorz);
definesquarebuttonclick(stackptr,170,192,200,217,4,7,imageSHFTR,shifthorz);
definesquarebuttonclick(stackptr,200,192,230,217,4,7,imageSHFTRR,shifthorz);
definesquarebuttonclick(stackptr,230,192,260,217,4,7,imageSHFTUU,shiftvert);
definesquarebuttonclick(stackptr,260,192,290,217,4,7,imageSHFTU,shiftvert);
definesquarebuttonclick(stackptr,290,192,320,217,4,7,imageSHFTD,shiftvert);
definesquarebuttonclick(stackptr,320,192,350,217,4,7,imageSHFTDD,shiftvert);
definesquarebuttonclick(stackptr,350,192,371,205,7,3,imageTSHFTL,scrollhorz);
definesquarebuttonclick(stackptr,350,205,371,217,7,3,imageTSHFTU,scrollvert);
definesquarebuttonclick(stackptr,371,192,392,205,7,3,imageTSHFTR,scrollhorz);
definesquarebuttonclick(stackptr,371,205,392,217,7,3,imageTSHFTD,scrollvert);
setctrlbreakfs(exitoption);
teglsupervisor();
}